/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package figure;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author User
 */
public class Player extends JPanel  {
  public String name;
  
  public Player(String name)
  {
    this.setPreferredSize(new Dimension(80,20));
    this.setBackground(Color.white);
    this.add(new JLabel(name));
    this.addMouseListener(new NodeMouseListener(this));
    this.setVisible(true);
    this.name = name;
  }
  
  public String getName()
  {
    return name;
  }
  
        class NodeMouseListener extends MouseAdapter {
        JPanel panel;
        
        public NodeMouseListener(JPanel panel)
        {
          this.panel = panel;
        }
        
        public void mousePressed(MouseEvent event) {
          System.out.println(panel.getName());
        }
    }
  
}
